class Solution {
public:
    int triangularSum(vector<int>& nums) {
        
        while(nums.size()>1){
            vector<int> cur(nums.size()-1);
            for(int i=0;i<cur.size();++i){
                cur[i]=(nums[i]+nums[i+1])%10;
            }
            nums=cur;
        }
        
        return nums[0];
    }
};
